import React, { Component } from 'react';
import './index.css'
import { withRouter } from 'react-router-dom';

class Public extends Component {
  godetail(Id) {
    console.log(1);
    this.props.history.push({
      pathname: '/detail/' + Id,
      state: {
        Id
      }
    })
  }
  render() {
    return (
      <div className='Public-box' >
        <div className='title'>
          <div className='icon'></div>
          <span>{this.props.title}</span>
        </div>
        <ul>
          {this.props.data && this.props.data.filter(item => {
            return item.book_id != '1085'
          }).slice(0, 8).map(val => {
            return (
              <li key={val.book_name} className='item' onClick={() => this.godetail(val.book_id)}>
                <img src={val.cover_url} alt="" />
                <span>{val.book_name}</span>
              </li>
            )
          })}
        </ul>
      </div>
    );
  }
}
export default withRouter(Public)